<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Case_id extends CI_Controller {
  
  
	function __construct()
	{
		parent::__construct();
		
		 $this->load->helper(array('form', 'url'));
		 $this->load->model('case_model');			
	}
   
   public function index()
	{
	   $this->load->model('case_model');
	   $data['country']=$this->case_model->get_country();
	   $this->load->view('common/header');
	   $this->load->view('user/case',$data);
	}
	public function create_case()
	{
	 $this->load->library('form_validation');
	 $this->form_validation->set_rules('company_name', 'Company Name', 'required');
		$this->form_validation->set_rules('contact_person', 'Contact Person', 'required');
		$this->form_validation->set_rules('address', 'Address', 'required');
		$this->form_validation->set_rules('pin_code', 'Pin Code', 'required');
		$this->form_validation->set_rules('landline_no', 'Landline No.', 'required');
		$this->form_validation->set_rules('mobile_no', 'Mobile No.', 'required');
		$this->form_validation->set_rules('email_id', 'Email-ID', 'required');
		$this->form_validation->set_rules('model_no', 'Model No.', 'required');
		$this->form_validation->set_rules('product_no', 'Product No.', 'required');
		$this->form_validation->set_rules('serial_no', 'Serial No.', 'required');
		$this->form_validation->set_rules('password', 'Password', 'required');
		$this->form_validation->set_rules('operating_system', 'Operating System', 'required');
		$this->form_validation->set_rules('country_purchase', 'Country Of Purchase', 'required');
		$this->form_validation->set_rules('issue_reported', 'Issue Reported', 'required');
		$this->form_validation->set_rules('demo_diagnosis', 'Demo Diagnosis', 'required');
			if ($this->form_validation->run() == true)
            {	     
		 $insert = array(
	        'case_id'            =>$this->case_model->get_id(),
			'customer_company'   =>$this->input->post('company_name'),
			'customer_name'      =>$this->input->post('contact_person'),
			'customer_address'   =>$this->input->post('address'),
			'customer_pincode'   =>$this->input->post('pin_code'),
			'customer_landline'  =>$this->input->post('landline_no'),
			'customer_mobile'    =>$this->input->post('mobile_no'),
			'customer_email'     =>$this->input->post('email_id'),
			'model_no'           =>$this->input->post('model_no'),
		    'product_no'         =>$this->input->post('product_no'),
		    'serial_no'          =>$this->input->post('serial_no'),
		    'customer_password'  =>$this->input->post('password'),
		    'customer_os'         =>$this->input->post('operating_system'),
		    'country_purchase'   =>$this->input->post('country_purchase'),
	        'issue_reported'     =>$this->input->post('issue_reported'),
	        'enginer_diagnosis' =>$this->input->post('demo_diagnosis'),
	        'ac_adapter'         =>$this->input->post('adapter'),
	        'driver_cd'           =>$this->input->post('chk_driver'),
	        'bag'                 => $this->input->post('chk_bag'),
		    'hdd'                 => $this->input->post('chk_hdd'),
		    'power_cord'          => $this->input->post('chk_powercord'),
			'carrycase'            => $this->input->post('chk_carry'),
			'optical_drive'        => $this->input->post('chk_optical'),
			'modem_card'           =>$this->input->post('chk_fax'),
			'network_card'          =>$this->input->post('chk_network'),
			'memory'                =>$this->input->post('chk_memory'),
			'capacity'               =>$this->input->post('chk_capacity'),
			'tray'                   =>$this->input->post('chk_tray'),
			'battery_no'             =>$this->input->post('chk_battery'),
			 'cradle'                =>$this->input->post('chk_cradle'),
			 'fdd'                    =>$this->input->post('chk_fdd'),
			'itb'                      =>$this->input->post('chk_itb'),
		    'wireless_lan'             =>$this->input->post('chk_wireless'),);
	
	       $this->case_model->create_case($insert);
		   }
		   else
		   {
		   redirect('user/case_id');
		   }
		   
	
	}
}

